package org.elwiki.editor;

import org.eclipse.rap.json.JsonObject;
import org.eclipse.rap.json.JsonValue;
import org.eclipse.rap.rwt.RWT;
import org.eclipse.rap.rwt.client.service.ClientFileLoader;
import org.eclipse.rap.rwt.remote.AbstractOperationHandler;
import org.eclipse.rap.rwt.remote.Connection;
import org.eclipse.rap.rwt.remote.OperationHandler;
import org.eclipse.rap.rwt.remote.RemoteObject;
import org.eclipse.rap.rwt.service.ResourceManager;
import org.eclipse.swt.SWT;
import org.eclipse.swt.SWTException;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Layout;

public class ElWikiEditor extends Composite {
	private static final long serialVersionUID = -6947875256619459296L;

	ElWikiEditor(Composite parent) {
		this(parent, SWT.NONE);
	}

	public ElWikiEditor(Composite parent, int style) {
		this(parent, (RichTextEditorConfiguration) null, style);
	}

	public ElWikiEditor( Composite parent, RichTextEditorConfiguration editorConfig, int style ) {
	    super( parent, style );
	    // init editor configuration
	    if( editorConfig == null ) {
	      config = new RichTextEditorConfiguration();
	    } else {
	      config = editorConfig;
	    }
	    registerResources();
	    loadJavaScript();
	    Connection connection = RWT.getUISession().getConnection();
	    remoteObject = connection.createRemoteObject( REMOTE_TYPE );
	    remoteObject.setHandler( operationHandler );
	    remoteObject.set( "parent", getId( this ) );
	    remoteObject.set( "config", config.toJson() );
	  }
	
}
